/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.digitaldiary.validator;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.FacesValidator;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;

@FacesValidator("com.digitaldiary.validator.DobValidator")
public class DobValidator implements Validator{
      
    Date date;
    SimpleDateFormat sdf= new SimpleDateFormat("dd/MM/yyyy");

    @Override
    public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
        try {
            date= sdf.parse(value.toString());
        } catch (ParseException ex) {
           
        }
        System.out.println(date);
        if(date.getTime()>= (new Date()).getTime()){
            System.out.println("Enter   lkjl");
           FacesMessage msg= new FacesMessage("Invalid Date. Please check enter valid date");
           throw new ValidatorException(msg);
        }
    }
}
   
   

